package me.sdevil507.biz.fruit.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.sdevil507.supports.jpa.BaseJpaSnowflakeIdEntity;
import me.sdevil507.supports.upload.po.AttachFile;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: tips_back_end
 * @description: 成果与会领导
 * @author: kzl
 * @create: 2020-06-28 11:41
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "biz_fruit_leader")
@Where(clause="is_del = 0")
public class FruitLeaderPO  extends BaseJpaSnowflakeIdEntity {


    /**
     * 成果id
     */
    @Column
    private Long  fruitId;

    /**
     * 领导名称
     */
    @Column
    private String name;

    /**
     * 领导职务
     */
    @Column
    private String job;

    /**
     * 领导单位
     */
    @Column
    private String unit;

    /**
     * 批示时间
     */
    @Column
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date  inclinationTime;

    /**
     * 批示级别
     */
    @Column
    private String  inclinationLevel;

    @Formula("(select t.d_name from biz_sysdict as t  where t.d_value=inclination_level and t.type_key='InclinationsLevel')")
    private String  inclinationLevelName;

    /**
     * 批示内容
     */
    @Column
    private String inclinationComments;

    /**
     * 报送渠道
     */
    @Column
    private String subChannel;
    /**
     * 批示类型：1.肯定 2.否定 3.圈阅
     */
    @Column
    private String inclination;

    @Formula("(select t.d_name from biz_sysdict as t  where t.d_value=inclination and t.type_key='Inclinations')")
    private String inclinationName;


    /**相关批示附件**/
    @OneToMany(targetEntity = AttachFile.class, cascade= CascadeType.MERGE, orphanRemoval = true)
    @JoinColumn(name="relationId")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<AttachFile> attFiles =new ArrayList<>();

    /**
     * 创建时间
     */
    @Column
    private Date createTime = new Date();

    /**
     * 更新时间
     */
    @Column
    private Date updateTime = new Date();

    /**
     * 智库id
     */
    @Column
    private Long orgId;

    /**
     * 是否删除
     */
    @Column(nullable = false)
    private Boolean  isDel= false;

    /**
     * 批示录入部门  1： 江苏省委宣传部(仅在报送智库专报情况下)
     */
    @Column
    private Integer inputType;

}
